<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>document</title>
</head>
<body>
<a>点一下?</a>
<input type="button" id="btn1" value="设置属性">
<input type="button" id="btn2" value="删除属性">
<script>
    var btn1=document.getElementById("btn1");
    btn1.onclick=function(){
        var a = document.getElementsByTagName("a")[0];
        a.setAttribute("href","https://www.bilibili.com");
        //将a的超链接连接到b站
    }
    var btn2=document.getElementById("btn2");
    btn2.onclick=function(){
        var a = document.getElementsByTagName("a")[0];
        a.removeAttribute("href");
        //移除掉a的href属性;
    }
</script>
</body>
</html>